package ws.jdbc.concurrent.driver.sqlserver

/**
 *
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
class ResultSetCursorTest extends ResultSetTest {

  CStatement stmt

   /**
   * Run this before every test.
   */
  @Override
  void setUp() {
    super.setUp()

    stmt = (CStatement) con.createStatement()
    rs = stmt.executeQuery(sqlQuery)
  }

  void testLock() {
    println "testLock()"

    def t1 = Thread.start {
      def cursor = stmt.getCursor()

      cursor.lock()

      Thread.sleep(3000)
      cursor.next()
      println "T1"
      printLine(cursor)

      cursor.unlock()
    }

    def t2 = Thread.start {
      def cursor = stmt.getCursor()

      cursor.lock()

      cursor.next()
      println "T2"
      printLine(cursor)

      cursor.unlock()
    }

    t1.join()
    t2.join()
  }
}

